<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// Route::post('login', 'Api\Spa\Admin\LoginController@login')->name('login');
// // Route::middleware('auth:sanctum')->post('login', 'Api\Spa\Admin\LoginController@login');


// Route::middleware('auth:sanctum')->get('test', 'Api\Spa\Admin\TestController@test');

Route::post('user/login', 'Api\Spa\Admin\LoginController@login');

Route::middleware('auth:sanctum')->get('user/info', function () {
	return response()->json([
		'code' => 20000,
		'data' => [
			'roles' => ['admin'],
			'introduction' => 'I am a super administrator',
			'avatar' => 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
			'name' => 'Super Admin'
		]
	]);
});

Route::post('user/logout', 'Api\Spa\Admin\LoginController@logout');

Route::middleware(['auth:sanctum'])->group(function () {
	Route::get('user/session', function (Request $request) {
		// var_dump($request->session()->all());
		var_dump(Auth::user());
		// var_dump(Auth::id());
	});
});